<template>
<div class="vip-order views-container">
    <div class="wlm-table">
        <div class="wlm-table-header" style="margin-bottom:20px;">
            <div class="dashboard-header">
                <el-row :gutter="8" class="flex-row flex-align-c flex-justify-c">
                    <el-col :span="5">
                        <div class="dashboard-header-item flex-col flex-justify-c flex-align-c">
                            <div class="item-title"><span>平台添加数</span>
                                <el-popover placement="top-start"  trigger="hover">
                                    <div style="font-size:12px">后台添加用户成为会员的数量</div>
                                    <el-button style="color:#333333" type="text" slot="reference"><svg-icon icon-class="wenhao" style="font-size:20px"/></el-button>
                                </el-popover>
                            </div>
                            <div class="item-num">
                                <span>{{categoryData.adminNumber||'0'}}</span>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="dashboard-header-item flex-col flex-justify-c flex-align-c">
                            <div class="item-title"><span>用户购买数</span>
                                <el-popover placement="top-start"  trigger="hover">
                                    <div style="font-size:12px">用户直接购买会员电子卡的数量</div>
                                    <el-button style="color:#333333" type="text" slot="reference"><svg-icon icon-class="wenhao" style="font-size:20px"/></el-button>
                                </el-popover>
                            </div>
                            <div class="item-num">
                                <span>{{categoryData.buyNumber||'0'}}</span>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="dashboard-header-item flex-col flex-justify-c flex-align-c ">
                            <div class="item-title"><span>激活码兑换数</span>
                                <el-popover placement="top-start"  trigger="hover">
                                    <div style="font-size:12px">用户使用激活码成为会员的数量</div>
                                    <el-button style="color:#333333" type="text" slot="reference"><svg-icon icon-class="wenhao" style="font-size:20px"/></el-button>
                                </el-popover>
                            </div>
                            <div class="item-num">
                                <span>{{categoryData.cdKeyNumber||'0'}}</span>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="dashboard-header-item flex-col flex-justify-c flex-align-c ">
                            <div class="item-title"><span>购买商品数</span>
                                <el-popover placement="top-start"  trigger="hover">
                                    <div style="font-size:12px">购买指定商品成为会员的数量</div>
                                    <el-button style="color:#333333" type="text" slot="reference"><svg-icon icon-class="wenhao" style="font-size:20px"/></el-button>
                                </el-popover>
                            </div>
                            <div class="item-num">
                                <span>{{categoryData.buyGoodsNumber||'0'}}</span>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="dashboard-header-item flex-col flex-justify-c flex-align-c ">
                            <div class="item-title"><span>商品加购卡数</span>
                                <el-popover placement="top-start"  trigger="hover">
                                    <div style="font-size:12px">购买商品选择会员卡的数量</div>
                                    <el-button style="color:#333333" type="text" slot="reference"><svg-icon icon-class="wenhao" style="font-size:20px"/></el-button>
                                </el-popover>
                            </div>
                            <div class="item-num">
                                <span>{{categoryData.buyAndGoodsNumber||'0'}}</span>
                            </div>
                        </div>
                    </el-col>
                </el-row>
            </div>
        </div>
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.userTable.files" size="small" label-width="95px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="会员卡名称：">
                        <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.userTable.files.card_title" placeholder="请输入会员卡名称" style="width:160px;"></el-input>
                    </el-form-item>
                    <el-form-item label="开卡方式：">
                        <el-select v-model="tableFormatData.userTable.files.mode" placeholder="请选择" style="width:200px;">
                            <el-option label="全部" value="">
                            </el-option>
                            <el-option label="平台添加" :value="1">
                            </el-option>
                            <el-option label="用户购买" :value="2">
                            </el-option>
                            <el-option label="激活码兑换" :value="3">
                            </el-option>
                            <el-option label="购买商品" :value="4">
                            </el-option>
                            <el-option label="商品加购卡" :value="5">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="用户：">
                        <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.userTable.files.nickName" placeholder="请输入用户昵称或id" style="width:160px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button plain icon="document" :data-query="JSON.stringify(tableFormatData.userTable.files)" v-exceldown="{path:'exportMoList&',query: {}}">{{$t('excel.export') }}</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <el-table :ref="tableFormatData.userTable.key" :data="tableFormatData.userTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <!-- <el-table-column type="selection" width="55">
                </el-table-column> -->
                <el-table-column prop="date" label="交易单号" >
                    <template slot-scope="scope">
                        <span>{{scope.row.order_no || '-'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="会员卡名称" >
                    <template slot-scope="scope">
                        <span>{{scope.row.card_title || '-'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="会员" >
                    <template slot-scope="scope">
                        <div class="wlm-table-logos">
                            <img class="logo" :src="scope.row.avatarUrl">
                            <div class="inner-text">
                                <p>{{scope.row.nickName}}</p>
                                <span>ID:{{scope.row.user_id}}</span>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="是否续费" >
                    <template slot-scope="scope">
                        <span v-if="scope.row.card_mode==1">否</span>
                        <span v-if="scope.row.card_mode==2">是</span>
                        <span v-if="scope.row.card_mode==3">-</span>
                    </template>
                </el-table-column>
                <el-table-column label="会员卡号" >
                    <template slot-scope="scope">
                        <span>{{scope.row.card_number}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="开卡方式" >
                    <template slot-scope="scope">
                        <p v-if="scope.row.mode=='1'">平台添加</p>
                        <p v-if="scope.row.mode=='2'">用户购买</p>
                        <p v-if="scope.row.mode=='3'">激活码兑换</p>
                        <p v-if="scope.row.mode=='4'">购买商品</p>
                        <p v-if="scope.row.mode=='5'">商品加购卡</p>
                    </template>
                </el-table-column>
                <el-table-column label="支付总金额" >
                    <template slot-scope="scope">
                        <p>{{scope.row.pay_price || '-'}}</p>
                    </template>
                </el-table-column>
                <el-table-column label="下单时间"  min-width="90">
                    <template slot-scope="scope">
                        <span>{{scope.row.create_time}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="到期时间"  min-width="90">
                    <template slot-scope="scope">
                        <span>{{scope.row.card_end_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <el-button v-if="!scope.row.nickName&&!scope.row.can_delete" class="wlm-text" type="text" @click="delTableItem(scope.row.cdkey_id)">删除</el-button>
                            <span v-if="!!scope.row.nickName||!!scope.row.can_delete">-</span>
                        </div>
                    </template>
                </el-table-column> -->
            </el-table>
            <div class="pagination-content flex-row flex-justify-e flex-align-c">
                <!-- <el-row class="pagination-btns">
                    <el-checkbox class="check-all" true-label="1" false-label="0" v-model="tableFormatData.userTable.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row> -->
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.userTable.pagination.page" :page-sizes="tableFormatData.userTable.pagination.pagesizes" :page-size.sync="tableFormatData.userTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.userTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  MoList,
  destoryCdKey,
  pathNumberForMember
} from '@/api/application'
import exceldown from '@/directive/exceldown'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'VipOrder',
  components: {
  },
  directives: {
    exceldown
  },
  created() {
    this.$nextTick(() => {
      pathNumberForMember().then((response) => {
        const {
          data: {
            data: msgData = []
          }
        } = response
        this.categoryData = msgData
      })
    })
  },
  data() {
    return {
      selecStoreData: [],
      categoryData: [],
      blogTitle: '',
      initChooseUser: {
        closable: true,
        initList: []
      },
      tableFormatData: {
        current: 'userTable',
        userTable: {
          key: 'userTable',
          api: {
            getList: MoList,
            delList: destoryCdKey
          },
          tableData: [],
          files: {
            card_title: '',
            mode: '',
            nickName: '',
            ids: [],
            checkall: '0',
            Recycle: '1'
          },
          //   change: {
          //     status: {
          //       key: 'status',
          //       api: MoList
          //     }
          //   },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {
    saveDialogForm() {
      this.initChooseUser.initList = []
      this.resetDialogFormData({ card_id: '', method: 1, number: '' })
    },
    refreshSave() {
      this.formFormatSubmit()
      this.filesSerch()
    }
  }
}
</script>
